/*
 * TagCompound.h
 *
 *  Created on: 19 juin 2011
 *      Author: Pierrick Caillon <pierrick@megami.fr>
 */

#ifndef TAGCOMPOUND_H_
#define TAGCOMPOUND_H_

#include "NamedTag.h"
#include <vector>

namespace NamedBinaryTag
{

class DataFile;

class __attribute__((visibility("default"))) TagCompound: public NamedBinaryTag::NamedTag
{
private:
	std::vector<ITag*> items;
public:
	TagCompound();
	virtual ~TagCompound();

	TagTypes get_TagType() const;

	void Read(std::istream &input, bool ignoreName);
	void Write(std::ostream &output, bool ignoreName) const;

	bool Add(ITag *tag);
	bool Remove(ITag *tag);
	void Clear();
	bool Remove(std::string name);
	bool ContainsKey(std::string name);
	ITag *operator[](std::string name) const;
	size_t get_Count() const;
	ITag *get_Item(std::string name) const;
	std::vector<std::string> get_Keys() const;

	ITag *clone() const;
protected:
	TagCompound(void *root) : NamedTag(root) {}
	ITag *clone(void *newRoot) const;
	friend class DataFile;
};

}

#endif /* TAGCOMPOUND_H_ */
